Add browser-tab MCP demo#24
Merged
Merged
Conversation
commit: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 040a4dc. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Adds a tabbed in-browser demo to
www.captun.shso visitors can switch the editable fetch handler between:hello world, a tiny default responsechat room, the existing browser-backed chat demomcp server, a browser-tab MCP server sample using the MCP SDK from esm.shThe MCP sample exposes an
ask_questiontool backed bywindow.prompt(...), keeps MCP streamable HTTP transports by session id, and handles browser CORS explicitly in the visible snippet withwithCors(...).The hosted landing page now keeps the page script and demo snippets as readable dedented JavaScript source blocks before inserting them into the HTML, so the source no longer has to maintain deeply escaped inline JS strings.
Also makes the hosted landing page available on loopback dev origins and pins the hosted Wrangler config to the Iterate production account with the live
captun.sh/*and*.captun.sh/*routes.Verification
pnpm exec vitest run test/hosted-worker.test.tspnpm exec oxfmt --check src/hosted/site.ts test/hosted-worker.test.ts wrangler.hosted.jsoncpnpm exec oxlint src/hosted/site.ts test/hosted-worker.test.ts --threads 1 --deny-warningspnpm run typecheckpnpm exec wrangler deploy -c wrangler.hosted.jsonc --dry-run --outdir /tmp/captun-hosted-dry-run-ignoremewrangler dev src/hosted/worker.ts --name captun-public-local --compatibility-date 2026-05-15 --ip 127.0.0.1 --port 8789 --local --var CUSTOM_HOSTNAME:captun.sh, then curl/browser smoke checks for/,/captun.browser.js, and the MCP tab sourceCAPTUN_PUBLIC_E2E=1 pnpm exec vitest run test/public-hosted.test.tsLive deploy
Deployed the browser-tab MCP demo to
captun-publicas Worker version76c8c2dd-1b34-4bcb-b006-6295a9df5751, and verifiedhttps://www.captun.sh/serves the tabbed demo and explicitwithCorsMCP snippet. The latest source-readability refactor is verified locally and by Wrangler dry-run, but has not been redeployed.Note
Medium Risk
Pins live Cloudflare routes/account and expands the public demo surface (user-run code, MCP/CORS); core tunnel auth logic is largely unchanged but deploy misconfiguration would hit production.
Overview
Adds a tabbed in-browser demo on the hosted landing page (hello world, chat room, MCP server) with editable snippets built from dedented TypeScript source instead of heavily escaped inline HTML/JS.
The MCP tab runs streamable HTTP in the tab (SDK via esm.sh), an
ask_questiontool backed bywindow.prompt, per-session transports, and explicit CORS in the visible snippet. Tunnel teardown usesSymbol.dispose; creating a tunnel re-evaluates the editor (live edit-on-type refresh is removed)./captun.browser.jsis now produced at build time: esbuild bundlessrc/index.tsfor the browser (external capnweb on esm.sh) intobrowser-module.generated.ts, wired intobuild/deploy.Loopback dev serves the landing and
captun.browser.json localhost and uses folder-style tunnel paths (e.g./demo/...).wrangler.hosted.jsoncpins the production account andcaptun.sh/*.captun.shroutes and setskeep_names: false.Reviewed by Cursor Bugbot for commit d6e54b8. Bugbot is set up for automated code reviews on this repo. Configure here.